<?php
class Admin_Model_Upload
{
    public static function getUploadDir($dir = null)
    {
        $dir = $dir ? $dir : 'uploads';
        $uploadDir = PUBLIC_PATH . '/' . $dir;
        return $uploadDir;
    }

    public static function upload($fileId, $allowedExtensions = array('pdf'))
    {
        $dir = self::getUploadDir();
        $uploader = new My_Uploader($fileId);
	    $uploader->setAllowedExtensions($allowedExtensions);
	    $uploader->setAllowRenameFiles(true);
	    $result = $uploader->save($dir, $_FILES[$fileId]['name']);
	    return $result;
    }

    public static function remove($fileName, $dir = null)
    {
        $dir = self::getUploadDir($dir);
        $filePath = $dir . '/' . $fileName;
        if (file_exists($filePath)) {
            unlink($filePath);
        }
        return true;
    }
}